package com.eonmind.ai.mapper;

import com.eonmind.common.contract.data.base.BaseMongoMapper;
import com.eonmind.common.contract.enums.DelEnum;
import com.eonmind.common.contract.enums.StatusEnum;
import com.eonmind.common.provider.entity.ai.AiModel;
import com.eonmind.common.provider.entity.ai.AiModelCategory;
import com.mongoplus.conditions.query.QueryWrapper;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AiModelCategoryMapper extends BaseMongoMapper<AiModelCategory> {

    public List<AiModelCategory> selectAllByStatus(Integer code) {
        if (code == null) {
            return List.of();
        }
        QueryWrapper<AiModelCategory> eq = createMgoQuery()
                .eq(AiModelCategory::getModelCategoryStatus, code)
                .eq(AiModelCategory::getDel, DelEnum.UN_DEL.getCode());
        return list(eq);
    }

    public AiModelCategory selectById(Long modelCategoryId) {
        QueryWrapper<AiModelCategory> eq = createMgoQuery()
                .eq(AiModelCategory::getId, modelCategoryId)
                .eq(AiModelCategory::getModelCategoryStatus, StatusEnum.OPENED.getCode())
                .eq(AiModelCategory::getDel, DelEnum.UN_DEL.getCode());
        return one(eq);
    }
}
